package com.ruoyi.stock.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.stock.domain.StockDfcf;
import com.ruoyi.stock.service.IStockDfcfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 东方财富数据Controller
 * 
 * @author ruoyi
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/stock/dfcf")
public class StockDfcfController extends BaseController
{
    @Autowired
    private IStockDfcfService stockDfcfService;

    /**
     * 查询东方财富数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(StockDfcf stockDfcf)
    {
        startPage();
        List<StockDfcf> list = stockDfcfService.selectStockDfcfList(stockDfcf);
        return getDataTable(list);
    }

    /**
     * 导出东方财富数据列表
     */
    @Log(title = "东方财富数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockDfcf stockDfcf)
    {
        List<StockDfcf> list = stockDfcfService.selectStockDfcfList(stockDfcf);
        ExcelUtil<StockDfcf> util = new ExcelUtil<StockDfcf>(StockDfcf.class);
        util.exportExcel(response, list, "东方财富数据数据");
    }

    /**
     * 获取东方财富数据详细信息
     */
    @GetMapping(value = "/getLastData")
    public AjaxResult getLastData() throws Exception {
        return success(stockDfcfService.insertStockDfcfAll());
    }

    /**
     * 获取东方财富数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stockDfcfService.selectStockDfcfById(id));
    }

    /**
     * 新增东方财富数据
     */
    @Log(title = "东方财富数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockDfcf stockDfcf)
    {
        return toAjax(stockDfcfService.insertStockDfcf(stockDfcf));
    }

    /**
     * 修改东方财富数据
     */
    @Log(title = "东方财富数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockDfcf stockDfcf)
    {
        return toAjax(stockDfcfService.updateStockDfcf(stockDfcf));
    }

    /**
     * 删除东方财富数据
     */
    @Log(title = "东方财富数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stockDfcfService.deleteStockDfcfByIds(ids));
    }
}
